package com.ruoyi.project.bajiaostar.jbhWetrademark.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.jbhWetrademark.domain.JbhWetrademark;
import com.ruoyi.project.bajiaostar.jbhWetrademark.service.IJbhWetrademarkService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 商标库Controller
 * 
 * @author 写烧糊
 * @date 2024-07-18
 */
@Controller
@RequestMapping("/bajiaostar/jbhWetrademark")
public class JbhWetrademarkController extends BaseController
{
    private String prefix = "bajiaostar/jbhWetrademark";

    @Autowired
    private IJbhWetrademarkService jbhWetrademarkService;

    @RequiresPermissions("bajiaostar:jbhWetrademark:view")
    @GetMapping()
    public String jbhWetrademark()
    {
        return prefix + "/jbhWetrademark";
    }

    /**
     * 查询商标库列表
     */
    @RequiresPermissions("bajiaostar:jbhWetrademark:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JbhWetrademark jbhWetrademark)
    {
        startPage();
        List<JbhWetrademark> list = jbhWetrademarkService.selectJbhWetrademarkList(jbhWetrademark);
        return getDataTable(list);
    }

    /**
     * 导出商标库列表
     */
    @RequiresPermissions("bajiaostar:jbhWetrademark:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JbhWetrademark jbhWetrademark)
    {
        List<JbhWetrademark> list = jbhWetrademarkService.selectJbhWetrademarkList(jbhWetrademark);
        ExcelUtil<JbhWetrademark> util = new ExcelUtil<JbhWetrademark>(JbhWetrademark.class);
        return util.exportExcel(list, "jbhWetrademark",null);
    }

    /**
     * 新增商标库
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商标库
     */
    @RequiresPermissions("bajiaostar:jbhWetrademark:add")
    @Log(title = "商标库", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JbhWetrademark jbhWetrademark)
    {
        return toAjax(jbhWetrademarkService.insertJbhWetrademark(jbhWetrademark));
    }

    /**
     * 修改商标库
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JbhWetrademark jbhWetrademark = jbhWetrademarkService.selectJbhWetrademarkById(id);
        mmap.put("jbhWetrademark", jbhWetrademark);
        return prefix + "/edit";
    }

    /**
     * 修改保存商标库
     */
    @RequiresPermissions("bajiaostar:jbhWetrademark:edit")
    @Log(title = "商标库", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JbhWetrademark jbhWetrademark)
    {
        return toAjax(jbhWetrademarkService.updateJbhWetrademark(jbhWetrademark));
    }

    /**
     * 删除商标库
     */
    @RequiresPermissions("bajiaostar:jbhWetrademark:remove")
    @Log(title = "商标库", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jbhWetrademarkService.deleteJbhWetrademarkByIds(ids));
    }
}
